package com.webSite.demo.cy.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.webSite.demo.cy.bean.HomeIndex;

@Mapper
public interface HomeIndexMapper extends BaseMapper<HomeIndex>{

	/**
	 * 添加
	* @Title: insertHome  
	* @Description: TODO(添加)  
	* @param @param home    参数  
	* @return void    返回类型  
	* @throws
	 */
	@Insert(value="insert into home_index (home_title,home_content,home_about1,home_about2,"
			+ "home_menu1,home_menu2,home_menu3,home_menu4,home_menu5,home_menu6,created,updated) "
			+ "value(#{homeTitle},#{homeContent},#{homeAbout1},#{homeAbout2},#{homeMenu1},"
			+ "#{homeMenu2},#{homeMenu3},#{homeMenu4},#{homeMenu5},#{homeMenu6},#{created},#{updated})")
	int insertHome(HomeIndex home);
	
	/**
	 * 查询最新的一条
	* @Title: findLimitOne  
	* @Description: TODO(根据id排序)  
	* @param @return    参数  
	* @return HomeIndex    返回类型  
	* @throws
	 */
	@Select(value="select home_title as homeTitle,home_content as homeContent,home_about1 as homeAbout1 ,home_about2 as homeAbout2,home_menu1 as homeMenu1 ,home_menu2 as homeMenu2,home_menu3 as homeMenu3,home_menu4 as homeMenu4,home_menu5 as homeMenu5,home_menu6 as homeMenu6 from home_index order by id desc limit 1")
	HomeIndex findLimitOne();
	
	/**
	 * 修改首页模板
	* @Title: updateHome  
	* @Description: TODO()  
	* @param @param home    参数  
	* @return void    返回类型  
	* @throws
	 */
	@Update(value="update home_index set home_title=#{homeTitle},home_content=#{homeContent},"
			+ "home_about1=#{homeAbout1},home_about=2#{homeAbout2},home_menu1=#{homeMenu1},"
			+ "home_menu2=#{homeMenu2},home_menu3=#{homeMenu3},home_menu4=#{homeMenu4},"
			+ "home_menu5=#{homeMenu5},home_menu6=#{homeMenu6},created=#{created},updated=#{updated} where id=#{id}")
	void updateHome(HomeIndex home);
}
